package com.llseven.ai.spring.llseven.config;

/**
 * @author ywb
 * @date 2025-04-18 12:48
 */


import com.qiniu.storage.Configuration;
import com.qiniu.storage.Region;
import com.qiniu.storage.UploadManager;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import com.qiniu.util.Auth;

@org.springframework.context.annotation.Configuration
public class QiniuConfig {
    
    @Resource
    private QiniuProperties qiniuProperties;
    
    @Bean
    public Auth qiniuAuth() {
        return Auth.create(qiniuProperties.getAccessKey(), qiniuProperties.getSecretKey());
    }
    
    
    @Bean
    public Configuration qiniuRegionConfig() {
        // 可根据你的 Bucket 区域调整 Region
        return new Configuration(Region.autoRegion());
    }
    
    @Bean
    public UploadManager uploadManager(Configuration config) {
        return new UploadManager(config);
    }
    
    public String getBucket(String name) {
        return qiniuProperties.getBuckets().get(name);
    }
    
    public String getDefaultBucket() {
        return qiniuProperties.getBuckets().get("default");
    }
}
